require(['./config'],()=>{
	require(['template','header','footer','jquery','utils'],(template)=>{
		class Login{
			constructor(){
				this.init()
			}
			init(){
				$('#dl').on('click',()=>{
					const phone=$('#phone2').val()
					const pwd=$('#pwd2').val()
					let userList=localStorage.getItem('userList')
					if(userList){
						userList=JSON.parse(userList)
						const isExist =userList.some(user=>{
							return user.phone===phone && user.pwd===pwd
						})
						if(isExist){
							utils.setCookie('phone',phone,{path:'/'})
							
							$('#suc').show()
							$('#box').hide()
							
						}else{
							alert('用户名或密码错误，请重试')
						}
					}else{
						alert('请先注册')
						window.open("/html/register.html"); 
					}
				})
			}
		}
		new Login()
	})
})